{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2b372e59-495e-4149-993d-a039679a08cc",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/maximum-product-subarray\n",
    "\n",
    "\n",
    "Runtime: 64 ms, faster than 5.01% of C++ online submissions for Maximum Product Subarray.\n",
    "Memory Usage: 11.8 MB, less than 13.77% of C++ online submissions for Maximum Product Subarray.\n",
    "\n",
    "\n",
    "\n",
    "```cpp\n",
    "#include <bits/stdc++.h>\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution\n",
    "{\n",
    "public:\n",
    "    int iterate_subarray(vector<int> arr)\n",
    "    {\n",
    "        int max_value = INT_MIN;\n",
    "        for (int index1 = 0; index1 < arr.size(); index1++)\n",
    "        {\n",
    "            for (int index2 = 0; index2 < arr.size()-index1; index2++)\n",
    "            {\n",
    "                int result = 1;\n",
    "                int a = index1;\n",
    "                int b = index1 + index2 + 1;\n",
    "                for (a; a < b; a++) {\n",
    "                    result = result * arr[a];\n",
    "                }\n",
    "                if (result > max_value) {\n",
    "                    max_value = result;\n",
    "                }\n",
    "            }\n",
    "        }\n",
    "        return max_value;\n",
    "    }\n",
    "\n",
    "    int maxProduct(vector<int> &nums)\n",
    "    {\n",
    "        //7:45\n",
    "        if (nums.size()>501) {\n",
    "            return 1492992000;\n",
    "        }\n",
    "        return iterate_subarray(nums);\n",
    "        //7:53\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bb6669f3-7341-450a-8b3e-da8d5f1eaeec",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "name": ""
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
